package com.smarttiger.zero.admin.dto;

import com.smarttiger.zero.admin.entity.*;
import com.smarttiger.zero.admin.entity.ArgsModel;
import com.smarttiger.zero.admin.entity.LogicModel;
import org.springframework.beans.BeanUtils;

import java.util.ArrayList;
import java.util.List;


public class LogicDto extends BaseDto {


    private String name;

    private String className;

    private String note;

    private String systemCode;

    private String dataSourceId;

    private List<ArgsModel> argsModels;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getClassName() {
        return className;
    }

    public void setClassName(String className) {
        this.className = className;
    }

    public String getNote() {
        return note;
    }

    public void setNote(String note) {
        this.note = note;
    }

    public List<ArgsModel> getArgsModels() {
        return argsModels;
    }

    public void setArgsModels(List<ArgsModel> argsModels) {
        this.argsModels = argsModels;
    }

    public String getSystemCode() {
        return systemCode;
    }

    public void setSystemCode(String systemCode) {
        this.systemCode = systemCode;
    }

    public String getDataSourceId() {
        return dataSourceId;
    }

    public void setDataSourceId(String dataSourceId) {
        this.dataSourceId = dataSourceId;
    }

    static public LogicDto tranlate(LogicModel f){
        LogicDto t = new LogicDto();
        BeanUtils.copyProperties(f,t,"argsModels");
        return t;
    }

    static public LogicDto tranlateAll(LogicModel f){
        LogicDto t = new LogicDto();
        BeanUtils.copyProperties(f,t);
        List<ArgsModel> rall = new ArrayList<>();
        f.getArgsModels().forEach(e->{
            ArgsModel dto = new ArgsModel();
            BeanUtils.copyProperties(e,dto);
            rall.add(dto);
        });
        t.setArgsModels(rall);

        return t;
    }

    static public List<LogicDto> tranlateList(List<LogicModel> f){
        List<LogicDto> t = new ArrayList<>();
        f.forEach(e->{
            LogicDto dto = LogicDto.tranlate(e);
            t.add(dto);
        });
        return t;
    }


}
